package com.eupmt.lab3.persistence.ibatis.dao;

import com.eupmt.lab3.domain.TipusReparacio;
import com.ibatis.common.resources.Resources;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.DaoManagerBuilder;
import java.io.IOException;
import java.io.Reader;

/**
 *
 * @author sony
 */
public class TipusReparacioDaoManager {
    
    protected static TipusReparacioDaoManager instance = null;
    private TipusReparacioDAO tipusDAO = null;

    public TipusReparacioDaoManager() throws IOException {
        super();
        Reader readerDao = Resources.getResourceAsReader("com/eupmt/lab3/persistence/ibatis/daoConfig.xml");
        DaoManager daoManager = DaoManagerBuilder.buildDaoManager(readerDao);
        this.tipusDAO = (TipusReparacioDAO) daoManager.getDao(TipusReparacioDAO.class);
     
    }


    // Metodes TipusReparacioDaoManager
    public void saveTipusReparacio(TipusReparacio tipus) throws Exception{
        tipusDAO.saveTipusReparacio(tipus);
    }

    public TipusReparacio getTipusReparacioById(Integer id) throws Exception {
        return tipusDAO.getTipusReparacioById(id);
    }

    public void insertTipusReparacio(TipusReparacio tipus) throws Exception {
        tipusDAO.insertTipusReparacio(tipus);
    }

    public void updateTipusReparacio(TipusReparacio tipus) throws Exception {
        tipusDAO.updateTipusReparacio(tipus);
    }

    public void deleteTipusReparacio(TipusReparacio tipus) throws Exception {
        tipusDAO.deleteTipusReparacio(tipus);
    }


    public static TipusReparacioDaoManager getInstance() throws IOException {
        if(instance == null) {
            instance = new TipusReparacioDaoManager();
        }
        return instance;
    }
}
